#include <stdio.h>
#include <arpa/inet.h>

int main ()
{
    #if 0//inet_pton
    char *inet_str = "192.168.3.1";
    int inet_int ;

    inet_pton(AF_INET, inet_str, &inet_int);
    printf("%d\n",inet_int);
    unsigned char *ip = (char*)&inet_int;// int*4个字节，char*1个字节
    printf("%d.%d.%d.%d\n",*ip,*(ip+1),*(ip+2),*(ip+3));
    return 0 ;
    #endif

    #if 1// inet_ntop
    unsigned char ip[]={192,168,3,1};
    char ip_str[16] ;

    inet_ntop(AF_INET, &ip, ip_str, 16);
    printf("%s\n",ip_str);

    #endif
}